home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 343_02 / mainedge.c < prev    next >
C/C++ Source or Header  |  1992-03-17  |  4KB  |  127 lines

  1.  
  2.  
  3.  
  4.  
  5.        /***********************************************
  6.        *
  7.        *       file d:\cips\mainedge.c
  8.        *
  9.        *       Functions: This file contains
  10.        *          main
  11.        *
  12.        *       Purpose:
  13.        *          This file contains the main calling
  14.        *          routine in an edge detection program.
  15.        *
  16.        *       External Calls:
  17.        *          gin.c - get_image_name
  18.        *          numcvrt.c - get_integer
  19.        *                      int_convert
  20.        *          tiff.c - read_tiff_header
  21.        *          edge.c - quick_edge
  22.        *                   detect_edges
  23.        *          edge2.c - homogeneity
  24.        *                    difference_edge
  25.        *                    contrast_edge
  26.        *          edge3.c - gaussian_edge
  27.        *                    enhance_edges
  28.        *
  29.        *       
  30.        *       Modifications:
  31.        *          2 February 1991 - created
  32.        *
  33.        *************************************************/
  34.  
  35. #include "d:\cips\cips.h"
  36.  
  37.  
  38.  
  39. short the_image[ROWS][COLS];
  40. short out_image[ROWS][COLS];
  41.  
  42. main(argc, argv)
  43.    int argc;
  44.    char *argv[];
  45. {
  46.  
  47.    char name[80], name2[80];
  48.  
  49.    int  count, i, ie, il, j, le, length, ll, size, 
  50.         t, type, v, width;
  51.  
  52.  
  53.    struct   tiff_header_struct image_header;
  54.  
  55.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  56.    _setbkcolor(1);
  57.    _settextcolor(7);
  58.    _clearscreen(_GCLEARSCREEN);
  59.  
  60.    if(argc < 7){
  61.     printf("\n\nNot enough parameters:");
  62.     printf("\n");
  63.     printf("\n   usage: mainedge   in-file   out-file   type ");
  64.     printf("  threshold?   threshold-value   size");
  65.     printf("\n   recall type: 1-Prewitt     2-Kirsch        3-Sobel");
  66.     printf("\n                4-quick       5-homogeneity   6-difference");
  67.     printf("\n                7-contrast    8-gaussian      9-enhance");
  68.     printf("\n   threshold?   1-threshold on   2-threshold off\n");
  69.     exit(0);
  70.    }
  71.  
  72.    strcpy(name, argv[1]);
  73.    strcpy(name2, argv[2]);
  74.    int_convert(argv[3], &type);
  75.    int_convert(argv[4], &t);
  76.    int_convert(argv[5], &v);
  77.    int_convert(argv[6], &size);
  78.  
  79.    il = 1;
  80.    ie = 1;
  81.    ll = ROWS+1;
  82.    le = COLS+1;
  83.  
  84.    read_tiff_header(name, &image_header);
  85.  
  86.    length = (90 + image_header.image_length)/ROWS;
  87.    width  = (90 +image_header.image_width)/COLS;
  88.    count  = 1;
  89.    printf("\nlength=%d  width=%d", length, width);
  90.  
  91.    for(i=0; i<length; i++){
  92.       for(j=0; j<width; j++){
  93.         printf("\nrunning %d of %d", count, length*width);
  94.         count++;
  95.         if(type == 9)
  96.            enhance_edges(name, name2, the_image, out_image,
  97.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  98.                       le+j*COLS, v);
  99.         if(type == 8)
  100.            gaussian_edge(name, name2, the_image, out_image,
  101.                          il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  102.                          le+j*COLS, size, t, v);
  103.         if(type == 7)
  104.            contrast_edge(name, name2, the_image, out_image,
  105.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  106.                       le+j*COLS, t, v);
  107.         if(type == 6)
  108.            difference_edge(name, name2, the_image, out_image,
  109.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  110.                       le+j*COLS, t, v);
  111.         if(type == 5)
  112.            homogeneity(name, name2, the_image, out_image,
  113.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  114.                       le+j*COLS, t, v);
  115.         if(type == 4)
  116.            quick_edge(name, name2, the_image, out_image,
  117.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  118.                       le+j*COLS, t, v);
  119.         if(type == 3  ||  type == 2  ||  type == 1)
  120.            detect_edges(name, name2, the_image, out_image,
  121.                         il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  122.                         le+j*COLS, type, t, v);
  123.       }
  124.    }
  125.  
  126. }  /* ends main  */
  127.